home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 67 / IOPROG_67A.ISO / soft / Tools / mwsppv4.exe / USE SEARCH AND REPLACE.INFO < prev    next >
Encoding:
Text File  |  1998-01-06  |  1.8 KB  |  49 lines

  1. How to use search and replace
  2.  
  3. The IDE provides three basic kinds of search and replace functions. The first kind
  4. provides native search and replace within a file or document. The second kind provides a
  5. native search of a directory. The third kind provides access to search and replace from 
  6. a script.
  7.  
  8. The first and second capabilities use a common set of parameters which are exposed to 
  9. scripts in the FindParameters object. Search and replace scripts distributed with the
  10. IDE also use the FindParameter object. For example, this means that if you change 
  11. the case sensitive parameter in the Find In Files dialog, then that same value of case 
  12. sensitive will be used for all other searches until you change it.
  13.  
  14. The IDE also includes a Finder toolbar to make it easy to make changes. This tool bar
  15. incldues find next, find previous, find in open windows, find in files, replace next and
  16. replace in open windows commands. It also includes a combo box that displays the current
  17. search parameter and the current replace value. The search and replace histories are 
  18. updated after each search or replace operation. The search value is updated each time a 
  19. new selection is made in a line.
  20.  
  21. Using search and replace in a script can be a powerful tool. For example the following 
  22. script converts all HTML tags in a document to lower case.
  23.  
  24. function DoCommand()
  25. {
  26.     var editor = getActiveEditor();
  27.     if (editor)
  28.     {
  29.         var findData = editor.findFirst("<[^>]*>", 0, 0, true, true, true);
  30.         while(findData && findData.found)
  31.         {
  32.             var range = findData.range;
  33.             var text = editor.copy(range);
  34.         var lower = text.toLowerCase();
  35.         editor.replace(lower, range);
  36.             editor.findNext(findData);
  37.         }
  38.         editor.setActive();
  39.     }
  40. }
  41.  
  42.  
  43. Copyright ⌐ 1997-1998 - Modelworks Software
  44.  
  45.  
  46.  
  47.  
  48.  
  49.